﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta name="apple-itunes-app" content="app-id=591578609">
	<meta name="viewport" content="width=device-width"/>
	<meta name="description" content="筑学堂网校" />
	
	<script type="text/javascript">
	   //点击群组名字，进入本群组详细页面
	   function getGroupSingle(id){
		   window.open('query_group_main/'+id,'_blank');
	   }
	   
	   //申请加入弹出div显示
	   function showappadd(group_id,adopt_id){
	       document.getElementById('appadd').style.display="block";	
	       $("#group_id_hidd").attr("value",group_id);
	       $("#adopt_id_hidd").attr("value",adopt_id);
	       
       }
	   
	   function hidappadd(){
	       document.getElementById('appadd').style.display="none";				
       }
	   
	   //申请加入
	   function insertGroup(){
		      var group_id = $("#group_id_hidd").val();
	          var adopt_id = $("#adopt_id_hidd").val();
	       
		       if(""==adopt_id){
		    	   alert("群组创建者ID为空，请检查数据库");
		    	   return false;
		       }
			   var apply_txt = $("textarea[class='app_addarea']").val();
			   
			   //发起者ID
			   var sponsor_id = '${user_id}';
			   //接受者ID
			   var adopt_id = adopt_id;
				   
			   $.ajax({url: "query_homeGroup_member_add/"+group_id+"/"+sponsor_id+"/"+adopt_id+"/"+apply_txt, 
			       success: function(result){
		           if("success"==result){
		        	   alert("申请加入群组成功，等待审核！");
		        	   hidappadd();
		           }
		        }
			   });
		   
	   }
               
	   
	   //首页
	   function firstPage(){
			  $.ajax({ url: "query_homeGroup_hot/1/${pageSize}", 
				       success: function(result){
			              $("#tab1").html(result);
			           }
			  });
		}
	   
	   //上一页
	   function upPage(){
		      var pageNo = '${pageNo}';
		      var upNo = Number(pageNo) - 1 ;
		      if(Number(pageNo)>1){
		    	  $.ajax({ url: "query_homeGroup_hot/"+upNo+"/${pageSize}", 
				       success: function(result){
			              $("#tab1").html(result);
			           }
			     });
		      }
			  
		}
	   //下一页
	   function nextPage(){
		      var pageNo = '${pageNo}';
		      var sumPageNum = '${sumPageNum}';
		      var nextNo = Number(pageNo) + 1 ;
		      
		      if(Number(pageNo)<Number(sumPageNum)){
		    	  $.ajax({ url: "query_homeGroup_hot/"+nextNo+"/${pageSize}", 
				       success: function(result){
			              $("#tab1").html(result);
			           }
			     });
		      }
		}
	   //跳转页
	   function gotoPage(){
		      var pageNo = $("#hostSelect").val();
			  $.ajax({ url: "query_homeGroup_hot/"+pageNo+"/${pageSize}", 
				       success: function(result){
			              $("#tab1").html(result);
			           }
			  });
		}
	</script>
</head>

<body style="clear:both;align:center;">
	<!--热门群组-->
	<div id="tab1" class="home_hy_div02" style="display:block;">
		<div class="ms_tab1_text01">&nbsp;</div>
		
		<!-- 第一列 -->
		<div class="home_qz_divl" style="left:30px;">
		
		  <c:forEach items="${data.data}" var="li" varStatus="item">
		        <c:if test="${item.index % 2== 0}">
		             <div class="home_qz_div01"> 
					
						<!-- <div class="home_hy_div0101"> <a href="#"><img src="../images/home_images/qz00.jpg"/>	</a> </div> -->
						<a href="#" onclick="getGroupSingle('${li.group_id}')">
						   <div class="home_hy_div0101"> 
							   <c:if test="${li.group_img == null}">
									<img src="../images/home_images/qz00.jpg"/>  
								</c:if>
								<c:if test="${li.group_img != null}">
									<img src="${showImgURL}${li.group_img}"/> 
								</c:if>
						   </div>
						</a>
					
						<div class="home_qz_div0102">
							<table width="390px" height="80px" align="left">
								<tr >
									<td style="font-size:14px;font-weight:bold;height:30px;width:150px;" colspan="2"> 
									  <a href="#" onclick="getGroupSingle('${li.group_id}')"> ${li.group_nm} </a> 
									</td>
									<td style="width:90px;"> 
									   <c:if test="${user_id!=li.create_id && li.in_flag==0}">
									      <a href="#" style="color:#e2681f" onClick="showappadd('${li.group_id}','${li.create_id}')"> 申请加入 </a>
									   </c:if>
								    </td>
								</tr>
								<tr heigh="20px">
									<td colspan="3"> ${li.group_txt} </td>
								</tr>
								<tr heigh="20px">
									<td> 创建人：${li.user_rnm}</td>
									<td style="width:240px;" colspan="2"> ${li.create_dt} </td>
								</tr>
								<tr heigh="20px">
									<td style="width:120px;"> 成&nbsp;&nbsp;&nbsp;员：${ li.merber_cnt} </td>
									<td style="width:150px;"> 话&nbsp;&nbsp;&nbsp;题:${ li.topic_cnt} </td>
									<td style="width:90px;"> 活&nbsp;&nbsp;&nbsp;动:${ li.activity_cnt} </td>
								</tr>
							</table>
						</div>
					 </div>
					 
					 <%-- <c:if test="${item.index!=0 && item.index % 2== 0}">
					     <div class="home_qz_div00"> </div>
					 </c:if>  --%>
					  <div class="home_qz_div00"> </div>
		        
		        </c:if> 

		  </c:forEach>
			
		</div>
		
		<!-- 第二列 -->
		
		<div class="home_qz_divl" style="left:80px;">
		
		  <c:forEach items="${data.data}" var="li" varStatus="item">
		       
		        <c:if test="${item.index % 2 != 0}">
		             <div class="home_qz_div01"> 
					
						<!-- <div class="home_hy_div0101"> <a href="#"><img src="../images/home_images/qz00.jpg"/>	</a> </div> -->
						<a href="#" onclick="getGroupSingle('${li.group_id}')">
						   <div class="home_hy_div0101"> 
						      <!--  <img src="../images/home_images/qz00.jpg"/>  -->
						       <c:if test="${li.group_img == null}">
									<img src="../images/home_images/qz00.jpg"/>  
								</c:if>
								<c:if test="${li.group_img != null}">
									<img src="${showImgURL}${li.group_img}"/> 
								</c:if>
						    </div>
						    
						</a>
					
						<div class="home_qz_div0102">
							<table width="390px" height="80px" align="left">
								<tr >
									<td style="font-size:14px;font-weight:bold;height:30px;width:150px;" colspan="2"> 
									  <a href="#" onclick="getGroupSingle('${li.group_id}')"> ${li.group_nm} </a> 
									</td>
									<td style="width:90px;"> 
									  <c:if test="${user_id!=li.create_id && li.in_flag==0}">
									      <a href="#" style="color:#e2681f" onClick="showappadd('${li.group_id}','${li.create_id}')"> 申请加入 </a> 
									  </c:if>
								    </td>
								</tr>
								<tr heigh="20px">
									<td colspan="3"> ${li.group_txt} </td>
								</tr>
								<tr heigh="20px">
									<td> 创建人：${li.user_rnm}</td>
									<td style="width:240px;" colspan="2"> ${li.create_dt} </td>
								</tr>
								<tr heigh="20px">
									<td style="width:120px;"> 成&nbsp;&nbsp;&nbsp;员：${ li.merber_cnt} </td>
									<td style="width:150px;"> 话&nbsp;&nbsp;&nbsp;题:${ li.topic_cnt} </td>
									<td style="width:90px;"> 活&nbsp;&nbsp;&nbsp;动:${ li.activity_cnt} </td>
								</tr>
							</table>
						</div>
					 </div>
					 
					 <%-- <c:if test="${item.index!=0 && item.index % 2== 0}">
					     <div class="home_qz_div00"> </div>
					 </c:if>  --%>
					  <div class="home_qz_div00"> </div>
		        
		        </c:if> 
		  
			      
				 

		  </c:forEach>
			
			
		</div>
		
		<!--页面切换-->
		<div class="page_div">
			<div class="page_body"> <a href="#">
				<div class="kczx_divlb01" onclick="firstPage()">首&nbsp;页</div>
				</a>
				<div class="kczx_divlb02"></div>
				<a href="#">
				<div class="kczx_divlb01" onclick="upPage()">上一页</div>
				</a>
				<div class="kczx_divlb02"></div>
				<a href="#">
				<div class="kczx_divlb01" onclick="nextPage()">下一页</div>
				</a>
				<div class="kczx_divlb02"></div>
				<select class="kczx_divlb01 page_select" onchange="gotoPage()" id="hostSelect">
				    <c:forEach begin="1" end="${sumPageNum}" var="i">  
					     <option value="${i}" <c:if test="${pageNo == i}"> selected="selected" </c:if>  >
					        第${i}页
					     </option>
				     </c:forEach> 
				</select>
			</div>
		</div>
		<!--end页面切换--> 
		
	</div>
	
	
	<!--申请加入提示-->
	<div id="appadd" class="app_adddiv">
	<div style="position:relative;float:right;right:15px;width:3px;height:15px;top:4px;"> <a href="#" onClick="hidappadd()"><img src="../images/cha.png"></a> </div>
		<div class="app_addbody">
		
		 <b>提示：</b>提交申请后需要团队管理员审核通过才能加入团队
			<p> <b>申请留言：</b></p>
		</div>
		<textarea class="app_addarea">
	
	</textarea>
		<p class="app_addtext"> 可以填写您的自我介绍，或者对群主的留言；字数限制为500字</p>
		<a href="#">
		<div class="app_button" onclick="insertGroup()"> 申请加入 </div>
		<input type="hidden" id="group_id_hidd" value=""/>
		<input type="hidden" id="adopt_id_hidd" value=""/>
		</a> </div>
	<!--end申请加入提示-->
</body>
</html>